<% layout('/layouts/default.html', {title: '考核任务通知表管理', libs: ['validate','fileupload']}){ %>
<div class="main-content">
	<div class="box box-main">
		<div class="box-header with-border">
			<div class="box-tools pull-right">
			</div>
		</div>
		<#form:form id="inputForm" model="${dcSupExamNotice}" action="${ctx}/notice/dcSupExamNotice/save" method="post" class="form-horizontal">
			<div class="box-body">
				<div class="row">

					<div class="col-xs-12">
						<div class="form-group">
							<label class="control-label col-sm-2" title="">
								<span class="required ">*</span> ${text('通知标题')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-10">
								<#form:hidden path="isNewRecord"/>
								<#form:hidden path="id" />
								<#form:hidden path="examId" maxlength="64" class="form-control "/>
								<#form:input path="noticeTitle" class="form-control required"/>
							</div>
						</div>
					</div>


					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required hide">*</span> ${text('通知类型')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8">
								<#form:select path="noticeType" dictType="dc_notice_type" blankOption="true" class="form-control" readonly="true"/>
							</div>
						</div>
					</div>
				</div>
				<div class="row">
					<div class="col-xs-12">
						<div class="form-group">
							<label class="control-label col-sm-2" title="">
								<span class="required ">*</span> ${text('通知内容')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-10">
								<#form:textarea path="noticeContent" rows="4" maxlength="500" class="form-control required"/>
							</div>
						</div>
					</div>
				</div>
				<div class="row">
					<div class="col-xs-12">
						<div class="form-group">
							<label class="control-label col-sm-2" title="">
								<span class="required ">*</span> ${text('报送单位')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-2">
								<#form:treeselect  title="${text('报送单位')}"
								path="noticeOrgs" labelValue="${officeName!}" labelPath="noticeOrgNames"
								url="${ctx}/sys/office/treeUnitData" type="text"
								class="required" isReturnValue="false" allowClear="true" canSelectRoot="true" canSelectParent="true"
								returnFullName="false" checkbox="true" chkboxType="{'Y':'','N':''}"
								placeholder="请选择报送单位"/>
							</div>
						</div>
					</div>
				</div>

				<div class="row">
					<div class="col-xs-12">
						<div class="form-group">
							<label class="control-label col-sm-2" title="">
								<span class="required hide">*</span> ${text('考核年度')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-2">
								<#form:select path="examYear" readonly="true" items="${yearList}" blankOption="true" data-placeholder="请选择" itemLabel="yearLabel" itemValue="yearValue" class="form-control width-120" defaultValue="${currentYear}"/>
							</div>
						</div>
					</div>
				</div>
				<div class="row">
					<div class="col-xs-12">
						<div class="form-group">
							<label class="control-label col-sm-2" title="">
								<span class="required ">*</span> ${text('报送时限')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-2">
								<#form:input path="noticeEndTime" readonly="true" maxlength="20" class="form-control laydate required"
								dataFormat="datetime" data-type="datetime" data-format="yyyy-MM-dd HH:mm"/>
							</div>
						</div>
					</div>
				</div>
				<div class="row">
					<div class="col-xs-12">
						<div class="form-group">
							<label class="control-label col-sm-2">
								<span class="required hide">*</span> ${text('附件上传')}：</label>
							<div class="col-sm-10">
								<#form:fileupload id="uploadFile" bizKey="${dcSupExamNotice.id}" bizType="dcSupExamNotice_file"
									uploadType="all" class="" readonly="false" preview="true" maxUploadNum="1"/>
							</div>
						</div>
					</div>
				</div>
			</div>
			<div class="box-footer">
				<div class="row">
					<div class="col-sm-offset-2 col-sm-10">
						<% if (hasPermi('notice:dcSupExamNotice:edit')){ %>
							<button type="submit" class="btn btn-sm btn-primary" id="btnSubmit"><i class="fa fa-check"></i> ${text('提 交')}</button>&nbsp;
						<% } %>
						<button type="button" class="btn btn-sm btn-default" id="btnCancel" onclick="js.closeCurrentTabPage()"><i class="fa fa-reply-all"></i> ${text('关 闭')}</button>
					</div>
				</div>
			</div>
		</#form:form>
	</div>
</div>
<% } %>
<script>
$("#inputForm").validate({
	submitHandler: function(form){
		js.ajaxSubmitForm($(form), function(data){
			js.showMessage(data.message);
			if(data.result == Global.TRUE){
				js.closeCurrentTabPage(function(contentWindow){
					contentWindow.page();
				});
			}
		}, "json");
    }
});
function treeselectCheck(id, nodes){
	var noticeOrgNames =$("#noticeOrgsName").val();
	var noticeOrgNamesArr = new Array();
	// var otherOrgNames =$("#otherOrgsName").val();
	// var otherOrgNamesArr = new Array();
	if (id == 'otherOrgs'){
		$.each(nodes,function (i,item) {
			// log("3333")
			if(noticeOrgNames.indexOf(item.name)!=-1){
				noticeOrgNamesArr.push(item.name);
			}
		})
		if(noticeOrgNamesArr.length != 0){
			var orgs = noticeOrgNamesArr.join();
			js.showMessage('区县报送单位'+orgs+'已经选择，请不要重复选择！');
			return false; // 验证失败，阻止关闭
		}
		// log(nodes); // 选择的节点数据
	}
	// if (id == 'noticeOrgs'){
	// 	$.each(nodes,function (i,item) {
	//
	// 		if(otherOrgNames.indexOf(item.name)!=-1){
	// 			otherOrgNamesArr.push(item.name);
	// 		}
	// 	})
	// 	if(otherOrgNamesArr.length != 0){
	// 		var orgs = otherOrgNamesArr.join();
	// 		js.showMessage('其它报送单位'+orgs+'已经选择，请不要重复选择！');
	// 		return false; // 验证失败，阻止关闭
	// 	}
	// 	log(nodes); // 选择的节点数据
	// }
	return true; // 验证成功
}
function treeselectCallback(id, act, index, layero, nodes){

	if (id == 'parent' && (act == 'ok' || act == 'clear')){
		var win = layero.iframeWindow();
		// log(win);    // 选择框内容的window对象
		// log(act);    // 回调活动事件（ok、clear、cancel）
		// log(index);  // layer的index
		// log(layero); // layer实例对象
		// log(selectData);  // 选择的节点数据
		// log(nodes);  // 选择的节点数据
	}
}
</script>